package com.glory.dgcpcpda.adapter;

import android.widget.FrameLayout;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.glory.dgcpcpda.R;
import com.glory.dgcpcpda.base.MyApp;
import com.glory.dgcpcpda.entity.SimpleEntity;
import com.pda.platform.ui.ui_pdaplatform.dialog.FreeUI_GeneralPop;
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_PopUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * FileName: ClearMaterielListAdapter
 * Author: XJH
 * Date: 2020/7/27 16:49
 * Description:
 * History:
 */
public class ClearMaterielListAdapter extends BaseQuickAdapter<SimpleEntity.MantissaLotBinData, BaseViewHolder> {
    private List<String> mActionList;
    public ClearMaterielListAdapter(@Nullable List<SimpleEntity.MantissaLotBinData> data) {
        super(R.layout.item_bin_info_list,data);
        mActionList = new ArrayList<>();
        mActionList.add("留站内");
        mActionList.add("返工");
        mActionList.add("报废");
        mActionList.add("分批");
        mActionList.add("分批出站");
        mActionList.add("分批报废");
    }

    @Override
    protected void convert(BaseViewHolder helper, SimpleEntity.MantissaLotBinData item) {
        helper.setText(R.id.list_tv1,item.getLOTID())
                .setText(R.id.list_tv2,item.getBINNAME())
                .setText(R.id.list_tv3,String.valueOf(item.getMAINQTY()))
                .setText(R.id.tvAction,item.getCLEARTYPE()).setGone(R.id.flActionList,true);
        FrameLayout mFlActionList = helper.getView(R.id.flActionList);
        mFlActionList.setOnClickListener(view -> {
            FreeUI_GeneralPop defectPop = FreeApi_PopUtils.getNormalPop(MyApp.app, mFlActionList.getWidth(), mActionList, helper.getView(R.id.ivActionArrow), (code, i) -> {
                helper.setText(R.id.tvAction,code);
                item.setCLEARTYPE(code);
            });
            FreeApi_PopUtils.setArrowShow(helper.getView(R.id.ivActionArrow));
            defectPop.showAsDropDown(mFlActionList, 0, 0);
        });

    }


}
